from time import sleep

from .servo_gpiozero import Servo

class Horizontal_Axis:
    LEFT=0
    RIGHT=1
    CENTER=2
   
    def __init__(self,pin,init_angle):
        self.servo=Servo(pin,init_angle)
        
        self.DICT_CMD_ACTION = {Horizontal_Axis.LEFT: self.turn_left,
                                Horizontal_Axis.RIGHT: self.turn_right,
                                Horizontal_Axis.CENTER: self.turn_center                               
                                }        
        self.each_step_angle=5

    def turn_left(self):
        self.servo.turn_clockwise(self.each_step_angle)
    
    def turn_right(self):
        self.servo.turn_anti_clockwise(self.each_step_angle)

    def turn_center(self):
        self.servo.turn_to_angle(90)
     
    def action(self, cmd_to_servo):
        self.DICT_CMD_ACTION[cmd_to_servo]()

